\(\int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx\) [48]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 32, antiderivative size = 95 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {(3 i A-B) x}{4 a^2}+\frac {A \log (\sin (c+d x))}{a^2 d}+\frac {3 A+i B}{4 a^2 d (1+i \tan (c+d x))}+\frac {A+i B}{4 d (a+i a \tan (c+d x))^2} \]

[Out]

-1/4*(3*I*A-B)*x/a^2+A*ln(sin(d*x+c))/a^2/d+1/4*(3*A+I*B)/a^2/d/(1+I*tan(d*x+c))+1/4*(A+I*B)/d/(a+I*a*tan(d*x+
c))^2

Rubi [A] (verified)

Time = 0.26 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.094, Rules used = {3677, 3612, 3556} \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {3 A+i B}{4 a^2 d (1+i \tan (c+d x))}-\frac {x (-B+3 i A)}{4 a^2}+\frac {A \log (\sin (c+d x))}{a^2 d}+\frac {A+i B}{4 d (a+i a \tan (c+d x))^2} \]

[In]

Int[(Cot[c + d*x]*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

-1/4*(((3*I)*A - B)*x)/a^2 + (A*Log[Sin[c + d*x]])/(a^2*d) + (3*A + I*B)/(4*a^2*d*(1 + I*Tan[c + d*x])) + (A +
 I*B)/(4*d*(a + I*a*Tan[c + d*x])^2)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3677

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(a*A + b*B)*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^(n + 1)/(2*
f*m*(b*c - a*d))), x] + Dist[1/(2*a*m*(b*c - a*d)), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Si
mp[A*(b*c*m - a*d*(2*m + n + 1)) + B*(a*c*m - b*d*(n + 1)) + d*(A*b - a*B)*(m + n + 1)*Tan[e + f*x], x], x], x
] /; FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] &&  !GtQ[n,
0]

Rubi steps \begin{align*} \text {integral}& = \frac {A+i B}{4 d (a+i a \tan (c+d x))^2}+\frac {\int \frac {\cot (c+d x) (4 a A-2 a (i A-B) \tan (c+d x))}{a+i a \tan (c+d x)} \, dx}{4 a^2} \\ & = \frac {3 A+i B}{4 a^2 d (1+i \tan (c+d x))}+\frac {A+i B}{4 d (a+i a \tan (c+d x))^2}+\frac {\int \cot (c+d x) \left (8 a^2 A-2 a^2 (3 i A-B) \tan (c+d x)\right ) \, dx}{8 a^4} \\ & = -\frac {(3 i A-B) x}{4 a^2}+\frac {3 A+i B}{4 a^2 d (1+i \tan (c+d x))}+\frac {A+i B}{4 d (a+i a \tan (c+d x))^2}+\frac {A \int \cot (c+d x) \, dx}{a^2} \\ & = -\frac {(3 i A-B) x}{4 a^2}+\frac {A \log (\sin (c+d x))}{a^2 d}+\frac {3 A+i B}{4 a^2 d (1+i \tan (c+d x))}+\frac {A+i B}{4 d (a+i a \tan (c+d x))^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.75 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.11 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {(7 A+i B) \log (i-\tan (c+d x))-8 A \log (\tan (c+d x))+(A-i B) \log (i+\tan (c+d x))+\frac {2 (A+i B)}{(-i+\tan (c+d x))^2}-\frac {2 (-3 i A+B)}{-i+\tan (c+d x)}}{8 a^2 d} \]

[In]

Integrate[(Cot[c + d*x]*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

-1/8*((7*A + I*B)*Log[I - Tan[c + d*x]] - 8*A*Log[Tan[c + d*x]] + (A - I*B)*Log[I + Tan[c + d*x]] + (2*(A + I*
B))/(-I + Tan[c + d*x])^2 - (2*((-3*I)*A + B))/(-I + Tan[c + d*x]))/(a^2*d)

Maple [A] (verified)

Time = 0.16 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.28

method result size
risch \(\frac {x B}{4 a^{2}}-\frac {7 i x A}{4 a^{2}}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} B}{4 a^{2} d}+\frac {{\mathrm e}^{-2 i \left (d x +c \right )} A}{2 a^{2} d}+\frac {i {\mathrm e}^{-4 i \left (d x +c \right )} B}{16 a^{2} d}+\frac {{\mathrm e}^{-4 i \left (d x +c \right )} A}{16 a^{2} d}-\frac {2 i A c}{a^{2} d}+\frac {A \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}{a^{2} d}\) \(122\)
derivativedivides \(-\frac {A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {i B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \,a^{2}}-\frac {3 i A \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {B \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}-\frac {3 i A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}+\frac {A \ln \left (\tan \left (d x +c \right )\right )}{a^{2} d}\) \(152\)
default \(-\frac {A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {i B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \,a^{2}}-\frac {3 i A \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {B \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}-\frac {3 i A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}+\frac {A \ln \left (\tan \left (d x +c \right )\right )}{a^{2} d}\) \(152\)

[In]

int(cot(d*x+c)*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/4*x/a^2*B-7/4*I*x/a^2*A+1/4*I*B/a^2/d*exp(-2*I*(d*x+c))+1/2/a^2/d*exp(-2*I*(d*x+c))*A+1/16*I/a^2/d*exp(-4*I*
(d*x+c))*B+1/16/a^2/d*exp(-4*I*(d*x+c))*A-2*I/a^2/d*A*c+1/a^2*A/d*ln(exp(2*I*(d*x+c))-1)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 86, normalized size of antiderivative = 0.91 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {{\left (4 \, {\left (7 i \, A - B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} - 16 \, A e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right ) - 4 \, {\left (2 \, A + i \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} - A - i \, B\right )} e^{\left (-4 i \, d x - 4 i \, c\right )}}{16 \, a^{2} d} \]

[In]

integrate(cot(d*x+c)*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/16*(4*(7*I*A - B)*d*x*e^(4*I*d*x + 4*I*c) - 16*A*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) - 1) - 4*(2*A
+ I*B)*e^(2*I*d*x + 2*I*c) - A - I*B)*e^(-4*I*d*x - 4*I*c)/(a^2*d)

Sympy [A] (verification not implemented)

Time = 0.27 (sec) , antiderivative size = 219, normalized size of antiderivative = 2.31 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {A \log {\left (e^{2 i d x} - e^{- 2 i c} \right )}}{a^{2} d} + \begin {cases} \frac {\left (\left (4 A a^{2} d e^{2 i c} + 4 i B a^{2} d e^{2 i c}\right ) e^{- 4 i d x} + \left (32 A a^{2} d e^{4 i c} + 16 i B a^{2} d e^{4 i c}\right ) e^{- 2 i d x}\right ) e^{- 6 i c}}{64 a^{4} d^{2}} & \text {for}\: a^{4} d^{2} e^{6 i c} \neq 0 \\x \left (- \frac {- 7 i A + B}{4 a^{2}} + \frac {\left (- 7 i A e^{4 i c} - 4 i A e^{2 i c} - i A + B e^{4 i c} + 2 B e^{2 i c} + B\right ) e^{- 4 i c}}{4 a^{2}}\right ) & \text {otherwise} \end {cases} + \frac {x \left (- 7 i A + B\right )}{4 a^{2}} \]

[In]

integrate(cot(d*x+c)*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))**2,x)

[Out]

A*log(exp(2*I*d*x) - exp(-2*I*c))/(a**2*d) + Piecewise((((4*A*a**2*d*exp(2*I*c) + 4*I*B*a**2*d*exp(2*I*c))*exp
(-4*I*d*x) + (32*A*a**2*d*exp(4*I*c) + 16*I*B*a**2*d*exp(4*I*c))*exp(-2*I*d*x))*exp(-6*I*c)/(64*a**4*d**2), Ne
(a**4*d**2*exp(6*I*c), 0)), (x*(-(-7*I*A + B)/(4*a**2) + (-7*I*A*exp(4*I*c) - 4*I*A*exp(2*I*c) - I*A + B*exp(4
*I*c) + 2*B*exp(2*I*c) + B)*exp(-4*I*c)/(4*a**2)), True)) + x*(-7*I*A + B)/(4*a**2)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(cot(d*x+c)*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.60 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.27 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {\frac {2 \, {\left (A - i \, B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a^{2}} + \frac {2 \, {\left (7 \, A + i \, B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{a^{2}} - \frac {16 \, A \log \left (\tan \left (d x + c\right )\right )}{a^{2}} - \frac {21 \, A \tan \left (d x + c\right )^{2} + 3 i \, B \tan \left (d x + c\right )^{2} - 54 i \, A \tan \left (d x + c\right ) + 10 \, B \tan \left (d x + c\right ) - 37 \, A - 11 i \, B}{a^{2} {\left (\tan \left (d x + c\right ) - i\right )}^{2}}}{16 \, d} \]

[In]

integrate(cot(d*x+c)*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/16*(2*(A - I*B)*log(tan(d*x + c) + I)/a^2 + 2*(7*A + I*B)*log(tan(d*x + c) - I)/a^2 - 16*A*log(tan(d*x + c)
)/a^2 - (21*A*tan(d*x + c)^2 + 3*I*B*tan(d*x + c)^2 - 54*I*A*tan(d*x + c) + 10*B*tan(d*x + c) - 37*A - 11*I*B)
/(a^2*(tan(d*x + c) - I)^2))/d

Mupad [B] (verification not implemented)

Time = 7.37 (sec) , antiderivative size = 129, normalized size of antiderivative = 1.36 \[ \int \frac {\cot (c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {\frac {B}{2\,a^2}-\frac {A\,1{}\mathrm {i}}{a^2}+\mathrm {tan}\left (c+d\,x\right )\,\left (\frac {3\,A}{4\,a^2}+\frac {B\,1{}\mathrm {i}}{4\,a^2}\right )}{d\,\left ({\mathrm {tan}\left (c+d\,x\right )}^2\,1{}\mathrm {i}+2\,\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )}+\frac {A\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{a^2\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (A-B\,1{}\mathrm {i}\right )}{8\,a^2\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (7\,A+B\,1{}\mathrm {i}\right )}{8\,a^2\,d} \]

[In]

int((cot(c + d*x)*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i)^2,x)

[Out]

(B/(2*a^2) - (A*1i)/a^2 + tan(c + d*x)*((3*A)/(4*a^2) + (B*1i)/(4*a^2)))/(d*(2*tan(c + d*x) + tan(c + d*x)^2*1
i - 1i)) + (A*log(tan(c + d*x)))/(a^2*d) - (log(tan(c + d*x) + 1i)*(A - B*1i))/(8*a^2*d) - (log(tan(c + d*x) -
 1i)*(7*A + B*1i))/(8*a^2*d)